import { baseToggleTableRule, moduleTypeRule } from "../options/base"
import { baseGetOrderList, getOrderDetails } from "./doCloud"
import { takeoutGetOrderList, takeoutGetSingleOrderDetails } from "./foodTakeout/orderMange"

export const toggleModule:baseToggleTableRule={
    foodTakeout:{
        name:`foodTakeout`,
        tableName:'food-order-list',
        update:{
            order_status:6
        },
        buildUpdate:(status)=>{
            return {
                order_status:status,
            }
        },
        // 获取单个订单的详细信息 
        getOrderDetails(orderId){
            const moduleName=`foodTakeout`;
            const moduleData=toggleModule[moduleName];
            return takeoutGetSingleOrderDetails.call(moduleData,orderId,moduleName)
        },
        // 获取订单列表
        getOrderList(queryWhere){
            return takeoutGetOrderList(queryWhere);
        }
    },
    runErrand:{
        name:`runErrand`,
        tableName:'admin-order-list',
        update:{
            rider_order_status:6
        },
        buildUpdate:(status)=>{
            return {
                rider_order_status:status
            }
        },
        // 获取单个订单的详细信息 
        getOrderDetails:(orderId)=>{
            const moduleName=`runErrand`;
            const moduleData=toggleModule[moduleName];
            return getOrderDetails.call(moduleData,orderId,moduleName)
        },
        // 获取订单列表
        getOrderList(queryWhere){
            const { module:moduleName }=queryWhere
            return baseGetOrderList(moduleName,queryWhere);
        }
    }
}

export const verifyModuleList:Array<moduleTypeRule>=[`foodTakeout`,`runErrand`];